<?php TPL::output('global/header.tpl.htm'); ?>

<link rel="stylesheet" type="text/css" href="<?php echo G_STATIC_URL; ?>/css/default/column.css?20180403">

<div class="aw-container-wrap">
    <div class="container">
        <div class="row clearfix">
            <div class="left-content col-sm-12 fl">
                <!--专栏-->
                <div class="first-box">
                    <div class="nav">
                        <ul class="nav nav-tabs aw-nav-tabs active hidden-xs">
                            <li class="column_hot"><a href="javascript:void(0)" data-column-sort="column_hot">热门</a></li>
                            <li class="column_new"><a href="javascript:void(0)" data-column-sort="column_new">最新</a></li>
                            <li class="column_score active"><a href="javascript:void(0)" data-column-sort="column_score">默认</a></li>
                            <h3><i class="icon icon-topic"></i> 专栏</h3>
                        </ul>
                    </div>

                    <div class="user-list clearfix">
                        <?php if($this->user_lists_count > 0){?>
                            <?php foreach($this->user_lists as $key => $val){?>
                                <?php $class = $key % 2 == 0 ? "show-left fl" : "show-right fr" ?>
                                <div class="<?php echo $class?> user-info clearfix">
                                    <div class="content-box1 clearfix fl">
                                        <div class="user-img fl">
                                            <a href="column/detail/uid-<?php echo $val['uid']?>">
                                                <img class="avatar" src="<?php echo get_avatar_url($val['uid'], 'mid'); ?>" />
                                            </a>
                                            <?php if($this->friend_uids){?>
                                                <?php if ($val['uid'] != $this->user_id AND $this->user_id) { ?>
                                                        <a class="follow <?php if (in_array($val['uid'],$this->friend_uids)){?>active<?php } ?>" data-uid="<?php echo $val['uid']?>"  href="javascript:void(0)">
                                                            <span>
                                                                <?php if (in_array($val['uid'],$this->friend_uids)){ ?>
                                                                    <input type="hidden" value="关注">
                                                                    <img src="<?php echo G_STATIC_URL; ?>/css/default/column_img/follow_del.png">
                                                                <?php } else {?>
                                                                    <input type="hidden" value="取消关注">
                                                                    <img src="<?php echo G_STATIC_URL; ?>/css/default/column_img/follow_add.png">
                                                                <?php }?>
                                                            </span>
                                                        </a>
                                                <?php }?>
                                            <?php }else{?>
                                                <a class="follow" href="<?php echo base_url()?>/?/account/login/">
                                                    <span>
                                                        <img src="<?php echo G_STATIC_URL; ?>/css/default/column_img/follow_add.png">
                                                    </span>
                                                </a>
                                            <?php }?>
                                        </div>
                                        <div class="content fl">
                                            <a href="column/detail/uid-<?php echo $val['uid']?>">
                                                <p class="nickname"><?php echo $val['user_name']?> <?php if ($val['verified']) { ?><i class="icon-v <?php if ($val['verified'] == 'enterprise') { ?> i-ve<?php } ?>" title="<?php if ($val['verified'] == 'enterprise') { ?>企业认证<?php } else { ?>个人认证<?php } ?>"></i><?php } ?></p>
                                            </a>
                                            <p class="digest">
                                                <!--测试数据暂无-->
                                            </p>
                                            <div>
                                                <?php $votes = isset($val['all_votes']) ? $val['all_votes'] : 0?>
                                                <?php if($votes > 10000){?>
                                                    <span>
                                                        <i class="icon icon-agree"></i>
                                                        <?php echo sprintf("%.1f",$votes / 10000) ?>万+
                                                    </span>
                                                <?php }else{ ?>
                                                    <span>
                                                        <i class="icon icon-agree"></i>
                                                        <?php echo $votes?>
                                                    </span>
                                                <?php }?>
                                                <span><img src="<?php echo G_STATIC_URL; ?>/css/default/column_img/fans.png">  <?php echo $val['fans_count']?></span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="content-box2 fl">
                                        <div>
                                            <?php $views = isset($val['all_views']) ? $val['all_views'] : 0 ?>
                                            <?php if($views >= 10000){?>
                                                <p>浏览量　<span><?php echo sprintf("%.1f",$views / 10000) ?></span>万+</p>
                                            <?php }else{ ?>
                                                <p>浏览量　<span><?php echo $views?></span></p>
                                            <?php }?>
                                            <p>文章数　<span><?php echo $val['article_count']?></span></p>
                                            <p>收益数　<span><?php echo ceil($val['all_coin'])?></span></p>　
                                        </div>
                                    </div>
                                </div>
                            <?php }?>
                        <?php }?>
                        <input id="user-list-page" type="hidden" data-page="1">
                        <input id="user-list-sort" type="hidden" data-column-sort="column_score">
                    </div>

                    <div class="replace">
                        <a href="javascript:void(0);">
                            <img src="<?php echo G_STATIC_URL; ?>/css/default/column_img/change.png"> 换一换</a>
                    </div>
                </div>
                <!--专栏 end-->

                <!--文章-->
                <div class="second-box">
                    <div class="nav">
                        <ul class="nav nav-tabs aw-nav-tabs active hidden-xs">
                            <li><a href="article/">更多</a></li>
                            <li class="article_hot"><a href="javascript:void(0)" data-article-sort="article_hot">热门</a></li>
                            <li class="article_new active"><a href="javascript:void(0)" data-article-sort="article_new">最新</a></li>
                            <h3><i class="icon icon-topic"></i> 文章</h3>
                        </ul>
                    </div>
                    <div class="article-list">
                        <ul>
                            <?php if(count($this->article_lists) > 0){?>
                                <?php
                                     foreach($this->article_lists as $key => $article){
                                      switch(($key + 1) % 3){
                                            case 1:
                                                $str = "first";
                                                break;
                                            case 2:
                                                $str = "second";
                                                break;
                                            case 0:
                                                $str = "three";
                                                break;
                                      }
                                ?>
                                    <li class="article-info aw-item <?php echo $str;?>">
                                        <?php if(get_article_cover_url($article['id'])){ ?>
                                            <a class="article-img" style="display:inline-block" href="article/<?php echo $article['id']?>">
                                                <!--<img src="/static/common/article-cover-min.png">-->
                                                <img src="<?php echo get_article_cover_url($article['id']); ?>?rand=<?php echo rand(1, 999); ?>">
                                            </a>
                                        <?php }?>
                                        <div class="content">
                                            <p class="article-title"><a href="article/<?php echo $article['id']?>"><?php echo $article['title']?></a></p>
                                            <p class="article-author"><?php echo $article['user_name']?></p>
                                            <div class="clearfix">
                                                <?php $votes = isset($article['votes']) ? $article['votes'] : 0;?>
                                                <?php if($votes >= 10000){?>
                                                    <span class="fl votes"><i class="icon icon-agree"></i> <?php echo sprintf("%.1f",$votes / 10000) ?>万+</span>
                                                <?php }else{ ?>
                                                    <span class="fl"><i class="icon icon-agree"></i> <?php echo $votes?></span>
                                                <?php }?>
                                                <span class="fr text-color-999"><img src="<?php echo G_STATIC_URL; ?>/css/default/column_img/time.png"> <?php echo date_friendly($article['add_time']); ?></span>
                                            </div>
                                        </div>
                                    </li>
                                <?php }?>
                            <?php }?>
                            <input id="article-page" type="hidden" data-page="1">
                            <input id="article-sort" type="hidden" data-article-sort="article_new">
                        </ul>

                        <div class="replace">
                            <a href="javascript:void(0);">
                                <img src="<?php echo G_STATIC_URL; ?>/css/default/column_img/change.png"> 换一换
                            </a>
                        </div>
                    </div>
                <!--文章 end-->
            </div>
            </div>

            <!--推荐作家-->
            <div class="right-content fr" >
                <div class="recommend-box">推荐作家</div>
                <div>
                    <?php if(count($this->recomend_lists) > 0){?>
                        <?php $i = 1 ?>
                        <?php foreach($this->recomend_lists as $val){?>
                            <?php $str = $i > 9 ? $i : "0".$i?>
                            <div class="recommend-item clearfix">
                                <div class="recommend-left fl">
                                    <div>
                                        <p>
                                            <a href="column/detail/uid-<?php echo $val['uid']?>">
                                                <img class="avatar" src="<?php echo get_avatar_url($val['uid'], 'mid'); ?>" />
                                                <span class="nickname"><?php echo $val['user_name']?> <?php if ($val['verified']) { ?><i class="icon-v <?php if ($val['verified'] == 'enterprise') { ?> i-ve<?php } ?>" title="<?php if ($val['verified'] == 'enterprise') { ?>企业认证<?php } else { ?>个人认证<?php } ?>"></i><?php } ?></span>
                                            </a>
                                        </p>
                                        <p class="digest">
                                            <!--测试数据暂无-->
                                        </p>
                                    </div>
                                    <div>
                                        <p class="clearfix"><span class="fl"><img src="<?php echo G_STATIC_URL; ?>/css/default/column_img/views.png"> 文章总浏览量</span> <span class="fr"><?php echo $val['all_views'] ? $val['all_views'] : 0 ?></span></p>
                                        <p class="clearfix"><span class="fl"><img src="<?php echo G_STATIC_URL; ?>/css/default/column_img/page_count.png"> 发表文章总数</span> <span class="fr"><?php echo $val['article_count'] ?></span></p>
                                    </div>
                                </div>
                                <div class="recommend-right fr"><?php echo $str?></div>
                            </div>
                            <?php $i++ ?>
                        <?php }?>
                    <?php }?>
                </div>
            </div>
            <!--推荐作家 end-->
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function(){
        $(".follow").click(function () {
            var _this = $(this);
            if (_this.hasClass('active'))
            {
                _this.find('input').val(_t('关注'));
            }
            else
            {
                _this.find('input').val(_t('取消关注'));
            }
            var url = '/follow/ajax/follow_people/';
            var data = {
                'uid': _this.attr("data-uid")
            };
            $.post(G_BASE_URL + url, data, function (result)
            {
                if (result.errno == 1)
                {
                    if (result.rsm.type == 'add')
                    {
                        _this.addClass('active');
                        _this.find("span").html(_t('<input type="hidden" value="关注"><img src="<?php echo G_STATIC_URL; ?>/css/default/column_img/follow_del.png" />'))
                    }
                    else
                    {
                        _this.removeClass('active');
                        _this.find("span").html(_t('<input type="hidden" value="取消关注"><img src="<?php echo G_STATIC_URL; ?>/css/default/column_img/follow_add.png" />'))
                    }
                }
                else
                {
                    if (result.err)
                    {
                        AWS.alert(result.err);
                    }

                    if (result.rsm.url)
                    {
                        window.location = decodeURIComponent(result.rsm.url);
                    }
                }
            }, 'json');
        });

        //专栏排序点击
        $(".first-box .nav ul li a").on('click',function(){
            var type = 'sort';
            var column_sort = $(this).attr("data-column-sort");
            var _this = $(this);
            $.ajax({
               type:'POST',
               url : G_BASE_URL + '/column/ajax/column_list_content/',
               data:{type:type,column_sort:column_sort},
               success:function(res){
                   $(".first-box .user-list").html(res);
                   _this.parent("li").addClass("active").siblings("li").removeClass("active");
               }
            });
        });

        //专栏 '换一换'点击
        $(".first-box .replace a").on('click',function(){
            var type = 'change';
            var page = $("#user-list-page").attr("data-page");
            var column_sort = $("#user-list-sort").attr("data-column-sort");
            $.ajax({
               type:'POST',
               url : G_BASE_URL + '/column/ajax/column_list_content/',
               data:{type:type,page:page,column_sort:column_sort},
               success:function(res){
                   $(".first-box .user-list").html(res);
                   $(".first-box .nav ul li."+column_sort).addClass("active").siblings("li").removeClass("active");
               }
            });
        });

        //文章 排序'点击
        $(".second-box .nav ul li a").on('click',function(){
            var type = 'sort';
            var article_sort = $(this).attr("data-article-sort");
            var _this = $(this);
            $.ajax({
               type:'POST',
               url : G_BASE_URL + '/column/ajax/article_list_content/',
               data:{type:type,article_sort:article_sort},
               success:function(res){
                   $(".second-box .article-list ul").html(res);
                   _this.parent("li").addClass("active").siblings("li").removeClass("active");
               }
            });
        });

        //文章 '换一换'点击
        $(".second-box .replace a").on('click',function(){
            var type = 'change';
            var page = $("#article-page").attr("data-page");
            var article_sort = $("#article-sort").attr("data-article-sort");
            $.ajax({
               type:'POST',
               url : G_BASE_URL + '/column/ajax/article_list_content/',
               data:{type:type,page:page,article_sort:article_sort},
               success:function(res){
                   $(".second-box .article-list ul").html(res);
                   $(".second-box .nav ul li."+article_sort).addClass("active").siblings("li").removeClass("active");
               }
            });
        });
    })

</script>
<?php TPL::output('global/footer.tpl.htm'); ?>